<template>
	<view class="djs">
		<u-count-down :time="time" @finish="finish" format="HH:mm:ss" autoStart millisecond @change="onChange">
			<view class="time">
				<view class="time__custom" :style="{backgroundColor:bgColor}">
					<text class="time__custom__item">{{ timeData.hours >= 10 ? timeData.hours : '0' + timeData.hours }}</text>
				</view>
				<text class="time__doc">:</text>
				<view class="time__custom" :style="{backgroundColor:bgColor}">
					<text class="time__custom__item">{{ timeData.minutes }}</text>
				</view>
				<text class="time__doc">:</text>
				<view class="time__custom" :style="{backgroundColor:bgColor}">
					<text class="time__custom__item">{{ timeData.seconds }}</text>
				</view>
			</view>
		</u-count-down>
	</view>
</template>

<script>
	export default {
		name:"djs",
		props:{
			bgColor:{
				type:String,
				default:'#000'
			},
			time:{
				type:Number|String,
				default:0
			}
		},
		data() {
			return {
				timeData:{}
			};
		},
		methods:{
			finish(){
				this.$emit('finish')
			},
			onChange(e){
				this.timeData = e;
			}
		}
	}
</script>

<style lang="scss" scoped>
.time {
	@include flex;
	align-items: center;
	&__custom {
		width: 22px;
		height: 22px;
		background-color: $base-color;
		border-radius: 4px;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: center;
		align-items: center;

		&__item {
			color: #fff;
			font-size: 20rpx;
			text-align: center;
		}
	}

	&__doc {
		color: #000000;
		padding: 0px 4px;
	}

	&__item {
		color: #606266;
		font-size: 15px;
		margin-right: 4px;
	}
}
</style>